import { router } from '@/router'
import { LoginRedirect, getToken } from '@/utils/auth'
// 路由守卫
router.beforeEach((to, from, next) => {
  console.log(to)
  if (from.query.from == 'wxlogin') {

  }
  if (to.meta.auth) {
    // if (to.path == from.path)
    //   return
    // alert('meta里有auth')
    const isLogin = getToken()
    // 已登录
    if (isLogin)
      next()

    else
      LoginRedirect()
  }
  else {
    console.log('不需要登录验证')
    // 不需要登录验证
    next()
  }
})
